<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>演员编辑</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../css/font.css">
		<link rel="stylesheet" href="../../css/weadmin.css">
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	</head>

	<body>
		<div class="weadmin-body">
			<form class="layui-form">
				<div class="layui-form-item">
					<label for="L_username" class="layui-form-label">
		                <span class="we-red">*</span>演员姓名
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="L_username" name="name" lay-verify="required|nikename" autocomplete="off" class="layui-input">
					</div>

				</div>

				<div class="layui-form-item">
					<label  class="layui-form-label">
		                <span class="we-red">*</span>手机
		            </label>
					<div class="layui-input-inline">
						<input type="text" id="L_phone" name="mobile" lay-verify="required|phone" autocomplete="" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<button class="layui-btn" lay-filter="add" lay-submit="">确定</button>
					<input type="hidden" name="id" id="id" value="" />
				</div>
			</form>
		</div>
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<script src="../../lib/jquery-2.1.1/jquery.js"></script>
		<script type="text/javascript">
			var id = localStorage.getItem("hostId");
			console.log(id)
			layui.extend({
				admin: '{/}../../js/admin'
			});
			layui.use(['form', 'jquery', 'admin','layer'], function() {
				var form = layui.form,
					$ = layui.jquery,
					admin = layui.admin,
					layer = layui.layer;
				//页面初始化加载
				$(function(){
					setTimeout(function(){
						frameVal();
					},100);
				});  
				function frameVal(){
					$('input[name="name"]').val(localStorage.getItem("performer_name"));
					$('input[name="mobile"]').val(localStorage.getItem("performer_mobile"));
					$('input[name="id"]').val(localStorage.getItem("performerId"));
					form.render();
				}
				//监听提交
				form.on('submit(add)', function(data) {
					console.log("tijiao",data.field);
					console.log()
					//发异步，把数据提交给php
					$.ajax({
						url:'/performer/update',
						data:data.field,
						success(res){
							layer.msg("修改成功")
							var index = parent.layer.getFrameIndex(window.name);
							window.parent.location.reload();//修改成功后刷新父界面

							//关闭当前frame
							parent.layer.close(index);

						},
						error(){
							layer.msg("修改失败")
							var index = parent.layer.getFrameIndex(window.name);
							//关闭当前frame
							parent.layer.close(index);
						}
					})

					return false;
				});

			});
		</script>
	</body>

</html>